import { mapGetters, mapMutations, mapActions } from 'vuex'
import { playMode } from 'common/js/config'

export const playlistMixin = {
    computed : {
        ...mapGetters([
            'playlist'
        ]),

    },
    mounted() {
        this.handlePlaylist(this.playlist)
    },
    activated () {
        this.handlePlaylist(this.playlist)
    },
    methods: {
        handlePlaylist () {
            throw new Error('component must implement handlePlaylist method')
        }
    }

}

export const playerMixin = {
    computed: {
        ...mapGetters([
            'playlist',
            'currentSong',

        ]),
        iconMode (){
            return this.mode === playMode.sequence
        },
        favoriteIcon(){

        },
    },
    methods: {
        toggleFavorite (song) {

        },
        ...mapMutations({
            setPlayMode: 'SET_PLAY_MODE',
            setPlaylist: 'SET_PLAYLIST',
            setCurrentIndex: 'SET_CURRENT_INDEX',
            setPlayingState: 'SET_PLAYING_STATE'
        }),
        ...mapActions([

        ])
    }
}
